package com.pactera.integral.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.pactera.integral.common.repository.ResultMap;
import com.pactera.integral.common.web.GenericController;
import com.pactera.integral.common.web.Response;
import com.pactera.integral.service.WXUserService;


@CrossOrigin
@RestController
@RequestMapping("/wx/user")
public class WXUserController extends GenericController {

	@Autowired
	private WXUserService userService;

	@RequestMapping(value = "/detail", method = RequestMethod.GET)
	public Response getUserDetail(@RequestParam String staffId) {
		return this.normal(userService.getUserDetail(staffId));
	}

	@RequestMapping(value = "/update/phone", method = RequestMethod.GET)
	public Response updatePhoneNumber(@RequestParam String staffId, @RequestParam String newPhone) {
		return this.normal(userService.updatePhoneNumber(staffId, newPhone));
	}
	
	@RequestMapping(value = "/update/password", method = RequestMethod.POST)
	public Response updatePassword(HttpServletRequest request) {
		return this.normal(userService.updatePassword(request));
	}
	
	@RequestMapping(value = "/info", method = RequestMethod.GET)
	public Response getSelfScoreAndRank(@RequestParam String staffId, @RequestParam Integer scoreType) {
		List<ResultMap<String, Object>> list = userService.searchSelfScoreAndRank(staffId, scoreType);

		return this.normal(list);
	}
}
